<template>
  <div>
    <nav-bar :position="'sticky'" 
      :isShadow="true"></nav-bar>
    <div class="banner">
      <div class="content"></div>
    </div>
    <nav-bar
      v-show="navShow"
      :position="'sticky'"
      :offset="0"
      :isShadow="true"
    ></nav-bar>
    <section>
      <div>
        <Title :title="'项目展示'" :is_link="false"></Title>
        <div class="flex justify-between margin-top-bg">
          <div
            class="item pointer wow fadeInUp"
            v-for="(item, index) in projectList"
            :key="index"
            @click="openUrl(index)"
          >
            <img :src="item.img_url" alt="" />
            <div class="title">{{ item.name }}</div>
            <div class="describe ellipsis3">{{ item.describe }}</div>
          </div>
        </div>
      </div>
    </section>
    <footbar></footbar>
  </div>
</template>
<script>
import NavBar from "@/components/nav/index";
import footbar from "@/components/footbar/index";
import Title from "@/components/title/index";
import { WOW } from "wowjs";
import $ from "jquery";
import {getProjectList} from '@/api/projectApi.js'
export default {
  name: "dynamic",
  components: { NavBar, footbar, Title },
  data() {
    return {
      projectList:[],
      navShow: false,
    };
  },
  mounted() {
    this.getProjectList()
    this.$store.commit("activeIndexChange", 2);
    this.$nextTick(() => {
      var wow = new WOW({
        live: false,
      });
      wow.init();
    });
    // window.scrollTop = 0
    $("html,body").animate(
      {
        scrollTop: $("#banner").outerHeight() || 0 + 1,
      },
      600
    );
    window.addEventListener("scroll", () => {
      let scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      if (scrollTop > 448) {
        this.navShow = true;
      } else {
        this.navShow = false;
      }
    });
  },
  methods: {
    async getProjectList(){
      let {data:{list}} = await getProjectList()
      let projectList = list
      this.projectList = projectList
    },
    play() {
      this.$refs.audio.play();
    },
    pause() {
      this.$refs.audio.pause();
    },
    currentTime() {
      console.log(this.$refs.audio.duration);
      console.log(this.$refs.audio.currentTime);
    },
    openUrl(index) {
      console.log(this.projectList[index]);
      if (this.projectList[index].href) {
        window.open(this.projectList[index].href)
      }
    },
  },
};
</script>

<style scoped>
.banner {
  width: 100%;
  margin-top: 60px;
  height: calc(100vh - 60px) ;
  background-image: url("../assets/images/banner/project.jpg");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  position: fixed;
  top: 0;
  z-index: 1;
  overflow: hidden;
}
.banner .content {
  width: 1200px;
  display: table-cell;
  height: 100%;
  position: relative;
  z-index: 1;
  text-align: center;
}
.banner .content .title {
  font-size: 50px;
  font-weight: bold;
  color: #ffffff;
  margin-top: 140px;
}
.banner .content .describe {
  font-size: 30px;
  font-weight: 400;
  color: #ffffff;
  margin-top: 47px;
}
section {
  background: #f4f4f4;
  padding:50px 0;
}
section > img {
  width: 100%;
}
section > div {
  width: 1140px;
  padding: 30px 30px 17px 30px;
  margin: 0 auto 0;
  background: #ffffff;
  position: relative;
  z-index: 2;
}
.flex {
  flex-wrap: wrap;
}
.item {
  width: 344px;
  border: 1px solid #eeeeee;
  margin-bottom: 40px;
}
.item > img {
  width: 344px;
  height: 206px;
  object-fit: cover;
}
.item .title {
  width: 291px;
  font-size: 16px;
  font-weight: 400;
  color: #666666;
  margin: 18px auto;
  text-align: left;
}
.item .describe {
  width: 291px;
  font-size: 14px;
  font-weight: 400;
  margin: 0 auto 18px;
  color: #999999;
  line-height: 24px;
}
</style>
